package com.qd.hik.token;

import com.qd.hik.dto.token.HkTokenResp;

/**
 * 〈一句话功能简述〉<br> 
 *
 * @author sjk
 * @create 2024-05-27 9:47
 * @since 1.0.0
 */
public class HkAccessTokenManager {
    private HkAccessTokenManager() {

    }

    private static final ThreadLocal<HkTokenResp> TOKEN_THREAD_LOCAL = new ThreadLocal<>();

    public static void setToken(HkTokenResp data) {
        TOKEN_THREAD_LOCAL.set(data);
    }

    public static HkTokenResp getToken() {
        return TOKEN_THREAD_LOCAL.get();
    }

    public static void clear() {
        final HkTokenResp hkTokenResp = getToken();
        if (null != hkTokenResp) {
            hkTokenResp.freeData();
        }
        TOKEN_THREAD_LOCAL.remove();
    }

}